package net.siufung.simple.config.mybatis.id;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 陈建峰
 * @since 2022/4/4 6:28 下午
 */
@Slf4j
public class MybatisIdGenerator implements IdentifierGenerator {

    @Override
    public Long nextId(Object entity) {
        Snowflake snowflake = IdUtil.getSnowflake(1, 1);
        return snowflake.nextId() + DateUtil.current();
    }

}
